import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { HumanService } from './service/human.service';
import { flyIn } from '../../common/animation/common.animation';
import { switchMap } from 'rxjs/operators';
@Component({
    templateUrl: './human-info.component.html',
    styleUrls: ['./human-info.component.scss'],
    animations: [flyIn]
})
export class HumanInfoComponent implements OnInit {
    human: any = {};
    constructor(
        private humanService: HumanService,
        private router: Router,
        private route: ActivatedRoute, ) { }

    ngOnInit(): void {
        this.route.paramMap.pipe(
            switchMap((params: ParamMap) => {
                this.human.humanId =  +params.get('id');
                this.human.unitId =  +params.get('unitId');
                return this.humanService.loadHumanById(this.human);
            })
        ).subscribe(human => this.human = human);
    }

}
